package net.sf.ivyide;

/**
 * User: janssk1
 * Date: 18-okt-2010
 * Time: 15:01:36
 */
public class ModuleRevisionId {

    private final ModuleId moduleId;
    private final String revision;

    public ModuleRevisionId(ModuleId moduleId, String revision) {
        this.moduleId = moduleId;
        this.revision = revision;
    }

    public String toString() {
        return moduleId + "#" + revision;
    }

    public String getName() {
        return getModuleId().getName();
    }

    public String getOrganisation() {
        return getModuleId().getOrganisation();
    }

    public ModuleId getModuleId() {
        return moduleId;
    }

    public String getRevision() {
        return revision;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ModuleRevisionId that = (ModuleRevisionId) o;

        if (!moduleId.equals(that.moduleId)) return false;
        if (!revision.equals(that.revision)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = moduleId.hashCode();
        result = 31 * result + revision.hashCode();
        return result;
    }
}
